export const RESERVATION_TIEM = new Map([
    [
        '1763',
        {
            time: '周三、周四',
            timeSlot: {
                ['3']: [
                    '13:30:00-14:15:00',
                    '14:35:00-15:20:00',
                    '15:50:00-16:40:00'
                ],
                ['4']: [
                    '08:30:00-09:15:00',
                    '09:35:00-10:20:00',
                    '10:40:00-11:30:00'
                ],
                ['5']: [
                    '08:30:00-09:15:00',
                    '09:35:00-10:20:00',
                    '10:40:00-11:30:00'
                ]
            }
        }
    ],
    [
        '1768',
        {
            time: '周一、周三',
            timeSlot: {
                ['1']: [
                    '13:30:00-14:15:00',
                    '14:35:00-15:20:00',
                    '15:40:00-16:30:00'
                ],
                ['3']: [
                    '08:30:00-09:15:00',
                    '09:35:00-10:20:00',
                    '10:40:00-11:30:00'
                ],
                ['5']: [
                    '08:30:00-09:15:00',
                    '09:35:00-10:20:00',
                    '10:40:00-11:30:00'
                ]
            }
        }
    ],
    [
        '0066',
        {
            time: '周一、周二',
            timeSlot: {
                ['1']: [
                    '08:30:00-09:15:00',
                    '09:35:00-10:20:00',
                    '10:40:00-11:30:00'
                ],
                ['2']: [
                    '13:30:00-14:15:00',
                    '14:35:00-15:20:00',
                    '15:40:00-16:30:00'
                ]
            }
        }
    ],
    [
        '1576',
        {
            time: '周二、周四',
            timeSlot: {
                ['2']: [
                    '08:30:00-09:15:00',
                    '09:35:00-10:20:00',
                    '10:40:00-11:30:00'
                ],
                ['4']: [
                    '13:30:00-14:15:00',
                    '14:35:00-15:20:00',
                    '15:40:00-16:30:00'
                ]
            }
        }
    ],
    [
        '0042',
        {
            time: '周二、周三',
            timeSlot: {
                ['2']: ['09:25:00-10:20:00'],
                ['3']: ['14:35:00-15:20:00']
            }
        }
    ]
]);

const isSelectBy = {
    ['0066']: new Set([1, 2]),
    ['1768']: new Set([1, 3]),
    ['1763']: new Set([3, 4]),
    ['1576']: new Set([2, 4]),
    ['0042']: new Set([2, 3])
};

const isNoSelect = d => {
    const currentDate = new Date(d);
    currentDate.setDate(currentDate.getDate() - 1);
    const date2023 = new Date(2023, 0, 1).getTime();

    const weeksPassed = Math.floor(
        (currentDate - date2023) / (7 * 24 * 60 * 60 * 1000)
    );

    // '从2023年1月1日至今已过去了' + weeksPassed + '周');
    // console.log(weeksPassed % 2);
    // 返回 0 就是李宇婷
    // 返回 1 就是荣宬

    return weeksPassed % 2;
};

export const checkWeekNumberBy0066 = dateString =>
    isSelectBy['0066'].has(new Date(dateString).getDay());

/**
 * 由于 1768 荣宬 和 1763 李宇婷 在周五轮流工作
 * */
export const checkWeekNumberBy1768 = dateString => {
    const day = new Date(dateString).getDay();

    if (day === 5) {
        return isNoSelect(dateString) === 1;
    }

    return isSelectBy['1768'].has(new Date(dateString).getDay());
};

export const checkWeekNumberBy1763 = dateString => {
    const day = new Date(dateString).getDay();

    if (day === 5) {
        return isNoSelect(dateString) === 0;
    }

    return isSelectBy['1763'].has(new Date(dateString).getDay());
};

export const checkWeekNumberBy1576 = dateString =>
    isSelectBy['1576'].has(new Date(dateString).getDay());

export const checkWeekNumberBy0042 = dateString =>
    isSelectBy['0042'].has(new Date(dateString).getDay());

export const CHEKC_WEEK_FN_MAP = {
    ['0066']: checkWeekNumberBy0066,
    ['1768']: checkWeekNumberBy1768,
    ['1763']: checkWeekNumberBy1763,
    ['1576']: checkWeekNumberBy1576,
    ['0042']: checkWeekNumberBy0042
};
